package com.longcai.service.fuyoupay.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.longcai.entity.payment.fuyou.request.ClyjFuyouWeixinRecord;
import com.longcai.fenzhuang.fuyou.BaseResponse;
import com.longcai.fenzhuang.fuyou.FuyouCommonPortMethod;
import com.longcai.mapper.fuyoupay.ClyjFuyouWeixinRecordMapper;
import com.longcai.service.fuyoupay.ClyjFuyouWeixinRecordService;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author f
 * @since 2019-04-23
 */
@Service
public class ClyjFuyouWeixinRecordServiceImpl extends ServiceImpl<ClyjFuyouWeixinRecordMapper, ClyjFuyouWeixinRecord> implements ClyjFuyouWeixinRecordService {
	@Autowired
	ClyjFuyouWeixinRecordMapper a;
	
	@Override
	public List<ClyjFuyouWeixinRecord> checkout(JSONObject params) {
		
		FuyouCommonPortMethod fcpm = new FuyouCommonPortMethod();
		ClyjFuyouWeixinRecord cfwr = new ClyjFuyouWeixinRecord();
		cfwr.setId(UUID.randomUUID().toString().replace("-", ""));
		cfwr.setTradeType(params.getString("tradeType"));
		cfwr.setPayType(params.getString("payType"));
		cfwr.setStartDay(params.getString("startDay"));
		cfwr.setEndDay(params.getString("endDay"));
		cfwr.setTxnSsn(params.getString("txnSsn"));
		cfwr.setSplitNum(params.getString("splitNum"));
		cfwr.setMchntTxnNum(params.getString("mchntTxnNum"));
		cfwr.setCustNo(params.getString("custNo"));
		cfwr.setTxnSt(params.getString("txnSt"));
		cfwr.setPageNo(params.getString("pageNo"));
		cfwr.setPageSize(params.getString("pageSize"));
		List<JSONObject> r = fcpm.weiXinRecord(cfwr);
		List<ClyjFuyouWeixinRecord> list= new ArrayList<>();
		for (JSONObject br: r) {
			cfwr.setFuiouOrder(br.getString("fuiouOrder"));
			cfwr.setOutCustNo(br.getString("outCustNo"));
			cfwr.setRespDesc(br.getString("respDesc"));
			cfwr.setTxnRspCd(br.getString("txnRspCd"));
			cfwr.setSplitNum(br.getString("splitNum"));
			cfwr.setOutArtifNm(br.getString("outArtifNm"));
			cfwr.setInFuiouAcctNo(br.getString("inFuiouAcctNo"));
			cfwr.setMchntTxndt(br.getString("mchntTxndt"));
			cfwr.setTradeType(br.getString("tradeType"));
			cfwr.setPayType(br.getString("payType"));
			cfwr.setTxnAmt(br.getString("txnAmt"));
			cfwr.setTxnAmtSuc(br.getString("txnAmtSuc"));
			cfwr.setTxnTime(br.getString("txnTime"));
			list.add(cfwr);
		}
		return list;
	}

}
